import request from "@/api/config";
import { AxiosPromise } from 'axios';
import {PORT} from "@/leadmall/api/config/servicePort";
import { KnowledgeCateVO, KnowledgeCateForm, KnowledgeCateQuery } from '@/leadmall/api/knowledgeCate/types';

/**
 * 查询知识库分类列表
 * @param query
 * @returns {*}
 */

export const listKnowledgeCate = (query?: KnowledgeCateQuery): AxiosPromise<KnowledgeCateVO[]> => {
  return request({
    url: PORT +'/leadmall/knowledgeCate/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询知识库分类详细
 * @param id
 */
export const getKnowledgeCate = (id: string | number): AxiosPromise<KnowledgeCateVO> => {
  return request({
    url: PORT +'/leadmall/knowledgeCate/' + id,
    method: 'get'
  });
};

/**
 * 新增知识库分类
 * @param data
 */
export const addKnowledgeCate = (data: KnowledgeCateForm) => {
  return request({
    url: PORT +'/leadmall/knowledgeCate',
    method: 'post',
    data: data
  });
};

/**
 * 修改知识库分类
 * @param data
 */
export const updateKnowledgeCate = (data: KnowledgeCateForm) => {
  return request({
    url: PORT +'/leadmall/knowledgeCate',
    method: 'put',
    data: data
  });
};

/**
 * 删除知识库分类
 * @param id
 */
export const delKnowledgeCate = (id: string | number | Array<string | number>) => {
  return request({
    url: PORT +'/leadmall/knowledgeCate/' + id,
    method: 'delete'
  });
};
